package IO;

import java.io.FileInputStream;
import java.io.FileOutputStream;

public class CopyDemo2 {
    public static void main(String[] args) throws Exception{

        FileInputStream fileInputStream = new FileInputStream("123.png");
        FileOutputStream fileOutputStream = new FileOutputStream("123_cop.png");

       /**/
       /* long start = System.currentTimeMillis();
        byte[] bytes = new byte[1024*10];
        while ((fileInputStream.read(bytes))!= -1){
            fileOutputStream.write(bytes);
        }
        long end = System.currentTimeMillis();
        System.out.println(end-start)*/;
        long start = System.currentTimeMillis();
        byte[] data = new byte[1024*10];
        int len;
        while ((len=fileInputStream.read(data))!=-1){
            fileOutputStream.write(data,0,len);
        }
        long end = System.currentTimeMillis();
        System.out.println(end-start);
    }
}
